/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package queenb.web.controller;

import java.util.List;
import queenb.net.entitybean.V020;
import queenb.web.store.V020Store;
import queenb.web.util.Util;

/**
 *
 * @author Hung.Ngo
 */
public class V020Controller extends QueenbController{
 private int fv050;
 private int beginContrustor;// result update
 private int pn100;
 private V020Store v020Store;
    public V020Controller()
    {
         v020Store = new V020Store();
        Object action = getRequest().getParameter("action");
        if(action!= null){
            if(action.equals("getIDFv050")){
                Object objectFV050 = getRequest().getParameter("FV050");
                fv050 = Util.parseInt(objectFV050);
            }else if(action.equals("addpersonalforTour")){
                Object obFn100 = getRequest().getParameter("pn100");
                Object objectFV050 = getRequest().getParameter("fv050");
                pn100 = Util.parseInt(obFn100);
                fv050 = Util.parseInt(objectFV050);
                System.out.println("--------- HAI PARAM ----"+ pn100+fv050);
                if(pn100!=0 && fv050!=0){
                    updateV020(pn100, fv050);
                }
            }
        }
    }

    public void updateV020(int pn100, int fv050){
        try {
            int count = v020Store.updateV020(fv050, pn100, null,null, getLogin().getUserName());
            if(count!=0){
                setBeginContrustor(1);
            }else{
                setBeginContrustor(0);
            }
        } catch (Exception e) {
        }
    }
    
    public List<V020> getListAllV020(){
        try {
            List<V020> itemlist = v020Store.getListV020(getLogin().getModule(), getLogin().getCompanyNo(), fv050, getLogin().getUserName());
            return itemlist;
        } catch (Exception e) {
            return null;
        }
    }
    
    /**
     * @return the fv050
     */
    public int getFv050() {
        return fv050;
    }

    /**
     * @param fv050 the fv050 to set
     */
    public void setFv050(int fv050) {
        this.fv050 = fv050;
    }

    /**
     * @return the beginContrustor
     */
    public int getBeginContrustor() {
        return beginContrustor;
    }

    /**
     * @param beginContrustor the beginContrustor to set
     */
    public void setBeginContrustor(int beginContrustor) {
        this.beginContrustor = beginContrustor;
    }

    /**
     * @return the pn100
     */
    public int getPn100() {
        return pn100;
    }

    /**
     * @param pn100 the pn100 to set
     */
    public void setPn100(int pn100) {
        this.pn100 = pn100;
    }
}
